// 引入公共方法
import './public.js';
const ncp = require('copy-paste')
// 打开应用
const robot = require("robotjs");
// 鼠标移动插件引用
const fs = require('fs');
const ks = require('node-key-sender');
const waitTime = 8000;
// 延时函数
const delayFn = (time) => {
    return new Promise((res, rej) => {
        setTimeout(() => {
            res()
        }, time);
    })
}
// 调用日报文件
const workTxt = (file) => {
    return new Promise((res, rej) => {
        fs.readFile(file, (a, b) => {
            if (!a) {
                res(b.toString())
            }
            rej()
        });
    })
}
const mainScript = async () => {
    await delayFn(waitTime);
    // 打开工作台
    robot.moveMouse(530, 570);
    robot.setMouseDelay(500)
    robot.mouseClick();
    // 打开日报
    robot.moveMouse(1130, 610);
    robot.setMouseDelay(500)
    robot.mouseClick();
    // 打开技术汇报
    robot.moveMouse(1180, 610);
    robot.setMouseDelay(500)
    robot.mouseClick();
    // 点击一下进行输入
    // await delayFn(500);
    robot.setMouseDelay(500);
    robot.mouseClick();
    await delayFn(3000);
    robot.moveMouse(1180, 560);
    robot.setMouseDelay(1500);
    robot.mouseClick();
    await ks.sendCombination(['control', 'ctrl', 'a']);
    robot.keyTap('backspace');
    const workTxtContent = await workTxt('./work.md');
    ncp.copy(workTxtContent, function () {
        ks.sendCombination(['control', 'ctrl', 'v']);
    })

    return
}
mainScript()